package com.example.robertluozizhao.framecollectdemo.activity.test.rongcloud.pinyin;


import com.example.robertluozizhao.framecollectdemo.activity.test.rongcloud.bean.Friend;

import java.text.Collator;
import java.util.Comparator;

/**
 * @author
 */
public class PinyinComparator implements Comparator<Friend> {

    public static PinyinComparator instance = null;

    public static PinyinComparator getInstance() {
        if (instance == null) {
            instance = new PinyinComparator();
        }
        return instance;
    }

    public int compare(Friend o1, Friend o2) {

        if (o1.getLetters().equals("@")
                || o2.getLetters().equals("#")) {
            return -1;
        } else if (o1.getLetters().equals("#")
                || o2.getLetters().equals("@")) {
            return 1;
        } else {
            if (o1.getLetters().equals(o2.getLetters())) {
                return o1.getName().compareTo(o2.getName());
            }else {
                return o1.getLetters().compareTo(o2.getLetters());
            }
        }

    }

}
